﻿namespace EyeOpen
{
	using System;
	using System.Collections.Generic;

	public class Container : IContainer
	{
		private readonly IDictionary<Type, object> controlSerializerDictionary = 
			new Dictionary<Type, object>();

		public void Register<T>(object obj)
		{
			controlSerializerDictionary
				.Add(typeof(T), obj);
		}

		public T Resolve<T>(object obj)
		{
			return 
				Resolve<T>(obj.GetType());
		}

		public T Resolve<T>()
		{
			return 
				Resolve<T>(typeof(T));
		}

		public T Resolve<T>(Type type)
		{
			if (!controlSerializerDictionary.ContainsKey(type))
			{
				return default(T);
			}

			return (T)controlSerializerDictionary[type];
		}
	}
}